/*
@Time : 2019/6/17 0017 20:51
@Author : visons
*/
package game_handler

import (
	"cellent_test/proto"
	"cellent_test/proto/msg"
	"cellent_test/proto/msgid"
	"fmt"
	"gitee.com/visons/gopkg/log"
	"github.com/davyxu/cellnet"
	proto2 "github.com/gogo/protobuf/proto"
)

func Init() {
	proto.Handler_GameHanlderREQ = func(ev cellnet.Event) {
		message := ev.Message().(*msg.GameHandlerREQ)
		switch message.HandlerId {
		case msgid.GameHandlerId_UserAddGoldREQ:
			req := &msg.UserAddGoldREQ{}
			err := proto2.Unmarshal(message.MessageData, req)
			if err != nil {
				log.Errorf("unmarshal fail")
			} else {
				fmt.Println(req.Gold)
			}

		default:

		}
	}
}
